/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package reflection;

import java.lang.reflect.Field;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Nguyen Minh Tan
 */
class Privateclass{
    private String hello = "\n\nHello World ^^!\n\n";
}
public class AccessPrivateField {

    public AccessPrivateField() {
        try {
            PrivateMethodClass p = new PrivateMethodClass();
            Field fi = p.getClass().getDeclaredField("hello");//Lấy trường tĩnh tên hello
            fi.setAccessible(true);//Cài đặt cho phép truy nhập thuộc tính private
            System.out.print(fi.get(p));
        } catch (Exception ex) {
            Logger.getLogger(AccessPrivateField.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    public static void main(String arg[]){
        new AccessPrivateField();
    }

}
/*


Hello World ^^!

 * */